import js from '@eslint/js'
import globals from 'globals'
import pluginVue from 'eslint-plugin-vue'
import { defineConfig } from 'eslint/config'

export default defineConfig([
  {
    files: ['**/*.{js,mjs,cjs,vue}'],
    plugins: { js },
    extends: ['js/recommended'],
  },
  {
    files: ['**/*.{js,mjs,cjs,vue}'],
    languageOptions: { globals: globals.browser },
  },
  pluginVue.configs['flat/essential'],
  {
    rules: {
      'no-unused-vars': 'warn',
      'no-undef': 'warn',
      semi: ['warn', 'never'],
      eqeqeq: 'error',
      // 'prefer-const': 'error',
      'no-const-assign': 'error',
      'no-var': 'error',
      'no-unneeded-ternary': 'error',
      curly: 'error',
      'no-duplicate-case': 2, // switch中的case标签不能重复
      'no-extra-semi': 2, // 禁止多余的冒号
      'no-multi-spaces': 1, // 不能用多余的空格
      'vue/multi-word-component-names': 'off',
    },
  },
  {
    ignores: ['dist/', '**/node_modules/'],
  },
])
